using Sponsorship.Domain;
using StructureMap.Configuration.DSL;

namespace Sponsorship.Infrastructure.BootStrapping.Registries
{
    /// <summary>
    /// Registers all command handlers (instances of <see cref="ICommandHandler{T}"/>) found in the assembly defining the <see cref="ICommandHandler{T}"/> type 
    /// (Sponsorship.Domain) with StructureMap.
    /// </summary>
    public class CommandHandlerRegistry : Registry
    {
        public CommandHandlerRegistry()
        {
            Scan( x => 
            {
                x.Assembly(typeof(ICommandHandler<>).Assembly);
                x.AddAllTypesOf(typeof(ICommandHandler<>));
            });
        }
    }
}